<template>
 <div>
      <el-container>
        <el-aside width="200px" style="margin-ringht:10px">
          <div class="icon"><span><h2>什锦的社区</h2></span><span><h3>个人中心</h3></span></div>
          <el-menu default-active="1" style="margin-right:30px;">
            <el-submenu index="1">
              <template slot="title"><i class="el-icon-caret-right"></i>用户管理</template>
              <el-menu-item-group>
                <el-menu-item index="1-1">
                <!--插入的地方-->
                  <router-link to="/user/profile">个人中心</router-link>
                </el-menu-item>
                <el-menu-item index="1-2">
                <!--插入的地方-->
                  <router-link to="/user/list">个人资料</router-link>
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title"><i class="el-icon-caret-right"></i>内容管理</template>
              <el-menu-item-group>
                <el-menu-item index="2-1">
                  <router-link to="/user/blog">博客管理</router-link>
                </el-menu-item>
                <el-menu-item index="2-2">
                  <router-link to="/user/question">问题管理</router-link>
                </el-menu-item>
                <el-menu-item index="2-3">
                  <router-link to="/user/comment">回答管理</router-link>
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>

        <el-container>
          <el-header  style="text-align: right; font-size: 12px">
            <div style="position: absolute;padding-top: 0px;right: 40%;font-size: 20px;font-weight: bold">welcome back</div>
            <el-dropdown>
                <el-image
                style="width: 50px; height: 50px;cursor:pointer;border-radius: 50%;margin-top:5px;margin-right:10px;"
                :src="url"
                >
            </el-image>
              <el-dropdown-menu slot="dropdown" >
                <el-dropdown-item @click.native="trunAdmin">返回首页</el-dropdown-item>
                <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-header>

          <el-main>
          <!--在这里展示视图-->
            <router-view @getAvatar="getAvatar"></router-view>
          </el-main>

        </el-container>
      </el-container>
      <Footer></Footer>
    </div>

</template>

<script>
import Footer from '../common/Footer'
  export default {
    name: 'AdminIndex',
    components:{Footer},
    data () {
      return {
        url:"123",
        dialogVisible: false,
        nickname:"",
      }
    },
    mounted () {},
    methods: {
      trunAdmin(){
        this.$router.push("/");
      },
      handleClick() {
        alert('button click');
      },
      logout(){
       var _this = this;
       this.$axios.get('/logout').then(resp => {
          if (resp.data.code === 200) {
            _this.$store.commit('logout')
            _this.$router.replace('/login')
          }
        })
      },
      getAvatar(data){
      this.url = data
      }

    },
  }
</script>

<style scoped lang="scss">
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  .el-aside {
    color: #333;
  }
  .icon{
    height: 100px;
    width: 150px;
    margin-top:20px;
    margin-left: 25px;
    color: deepskyblue;
    font-family: 华文行楷;
  }
</style>

